import random
capitals={'alabama':'montgomery','alaska':'june;au','arizona':'phoenix',
          'arkansas':'little rock','california':'scaramento','colorado':'denver',
          'connecticut':'hartford','delaware':'dover','florida':'tallahassee',
          'georgia':'atlanta','hawaii':'honolulu','idaho':'boise','illinois':'springfield',
          'indiana':'indianapolis','iowa':'des moines','kansas':'topeka',
          'kentucky':'frankfort','louisiana':'baton rouge','maine':'augusta',
          'maryland':'annapolis','massachusetts':'boston','michigan':'lansing',
          'minnesota':'saint paul','mississippi':'jackson','missouri':'jefferson city',
          'montana':'helena','nebraska':'lincoln','nevada':'carson city',
          'new hampshire':'concord','new jersey':'trenton','new mexico':'fanta fe',
          'new york':'albany','north carolina':'raleigh','north dakota':'bismarck',
          'ohio':'columbus','oklahoma':'oklahoma city','oregon':'salem',
          'pennsylvania':'harrisburg','rhode island':'providence','south carolina':'columbia',
          'south dakota':'pierre','tennessee':'nashville','texas':'austin',
          'utah':'salt lake city','vermont':'montpelier','virginia':'richmond',
          'washington':'olympia','west virginia':'charleston','wisconsin':'madison',
          'wyoming':'cheyenne'}
for quiznum in range(35):
  quizfile=open('capitalsquiz%s.txt'%(quiznum+1),'w')
  answerkeyfile=open('capitalsquiz_answers%s.txt'%(quiznum+1),'w')
  quizfile.write('name:\n\ndate:\n\nperiod:\n\n')
  quizfile.write((' '*20)+'state capitals quiz (form %s)'%(quiznum+1))
  quizfile.write('\n\n')
  states=list(capitals.keys())
  random.shuffle(states)
for questionnum in range(50):
  correctanswer=capitals[states[questionnum]]
  wronganswers=list(capitals.values())
  del wronganswers[wronganswers.index(correctanswer)]
  wronganswers=random.sample(wronganswers,3)
  answeroptions=wronganswers+[correctanswer]
  random.shuffle(answeroptions)
  quizfile.write('%s.what is the capital of %s?\n'%(questionnum+1,states[questionnum]))
  for i in range(4):
    quizfile.write('%s.%s\n'%('abcd',answeroptions[i]))
  quizfile.write('\n')
  answerkeyfile.write('%s.%s\n'%(questionnum+1,'abcd'[answeroptions.index(correctanswer)]))
quizfile.close()
answerkeyfile.close()

          
          
